Next | Prev | Up | Top | Contents | Index

Taking Timing Measurements

Timing, or benchmarking, parts of your program is an important part of tuning. It helps you determine which changes to your code have a noticeable effect on the speed of your application.

To achieve performance that is demonstrably close to the best the hardware can achieve, you can first follow the more general tuning tips provided here, but you then need to apply a rigorous and systematic analysis, as discussed in these section:

Benchmarking Basics

A detailed analysis involves examining what your program is asking the system to do and then calculating how long that should take, based on the known performance characteristics of the hardware. Compare this calculation of expected performance with the performance actually observed and continue to apply the tuning techniques until the two match more closely. At this point, you have a detailed accounting of how your program spends its time, and you are in a strong position both to tune further and to make appropriate decisions considering the speed-versus-quality trade-off.

The following parameters determine the performance of most applications:

Achieving Accurate Timing Measurements

Consider these guidelines to get accurate timing measurements:

Achieving Accurate Benchmarking Results

To benchmark performance for a particular code fragment, follow these steps:

  1. Determine how many polygons are being drawn and estimate how many pixels they cover on the screen. Have your program count the polygons when you read in the database.

    To determine the number of pixels filled, start by making a visual estimate. Be sure to include surfaces that are hidden behind other surfaces, and notice whether or not backface elimination is enabled. For greater accuracy, use feedback mode and calculate the actual number of pixels filled.

  2. Determine the transform and fill rates on the target system for the mode settings you are using.

    Refer to the product literature for the target system to determine some transform and fill rates. Determine others by writing and running small benchmarks.

  3. Divide the number of polygons drawn by the transform rate to get the time spent on per-polygon operations.

  4. Divide the number of pixels filled by the fill rate to get the time spent on per-pixel operations.

  5. Measure the time spent in the application.

    To determine time spent executing instructions in the application, perform the graphics-stubbing experiment described in "Finding Bottlenecks in Your Application".

This process takes some effort to complete. In practice, it's best to make a quick start by making some assumptions, then refine your understanding as you tune and experiment. Ultimately, you need to experiment with different rendering techniques and perform repeated benchmarks, especially when the unexpected happens.

Verify some of the suggestions presented in the following chapter. Try some techniques on a small program that you understand and use benchmarks to observe the effects. Figure 4-1 shows how you may actually go through the process of benchmarking and reducing bottlenecks several times.

Figure 4-1 : Flowchart of the Tuning Process


Benchmarking Basics
Achieving Accurate Timing Measurements
Achieving Accurate Benchmarking Results

Next | Prev | Up | Top | Contents | Index